import axios from 'axios';
import naive from 'naive-ui'
import { createApp } from 'vue'
import { createPinia } from 'pinia';
import {createDiscreteApi} from 'naive-ui'

import App from './App.vue'
import router from './router'
import store from './store'
import { AdminStore } from './store/User'


//服务端接口
axios.defaults.baseURL = "http://localhost:4080"

const app = createApp(App)

//创建naive独立api
const {message, notification,dialog} = createDiscreteApi(['message', 'dialog', 'notification'])

app.use(store)
app.use(naive)
app.use(router)
app.use(createPinia())

// 全局提供属性
app.provide("axios",axios)
app.provide("message",message)
app.provide("notification",notification)
app.provide("dialog",dialog)

const adminStore = AdminStore()
// axios拦截器
axios.interceptors.request.use((config)=>{
    //每次请求都在headers中添加token
    config.headers.token = adminStore.token
    return config
})


app.mount('#app')
